package com.ssmTest.service.impl;

import com.ssmTest.dao.IEmploymentAdDao;
import com.ssmTest.model.EmploymentAd;
import com.ssmTest.service.IEmploymentAdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service("employmentAdService")
public class EmploymentAdServiceImpl implements IEmploymentAdService {
    @Resource
    private IEmploymentAdDao iEmploymentAdDao;
    @Autowired
    private IEmploymentAdService iEmploymentAdService;

    //根据id查找
    public EmploymentAd selectEmploymentAd(int id) {
        return this.iEmploymentAdDao.selectEmploymentAd(id);
    }

    //插入信息
    public void insertEmploymentAd(EmploymentAd employmentAd) {
        this.iEmploymentAdDao.insertEmploymentAd(employmentAd);
    }

    //信息列表
    public List<EmploymentAd> EmploymentAdList(int toexamine) {
        return this.iEmploymentAdDao.EmploymentAdList(toexamine);
    }

    //更新Information
    public boolean updateInformationReasion(int id, String fail_reasion) {
        if (iEmploymentAdService.selectEmploymentAd(id) == null)
            return false;
        this.iEmploymentAdDao.updateInformation(id, fail_reasion);
        return true;
    }

    //更新Information
    public boolean updateEmploymentAd(EmploymentAd employmentAd) {
        if (iEmploymentAdService.selectEmploymentAd(employmentAd.getId()) == null)
            return false;
        this.iEmploymentAdDao.updateEmploymentAd(employmentAd);
        return true;
    }

    //关键字查询
    public List<EmploymentAd> selectSecondByAndKey(int pagenum,String city,String key){
        List<EmploymentAd> list= iEmploymentAdDao.selectSecondByAndKey((pagenum-1)*10,pagenum*10,city,key);
        return list;
    }

    public List<EmploymentAd> selectSecondByNoKey(int pagenum,String city){
        List<EmploymentAd> list= iEmploymentAdDao.selectSecondByNoKey((pagenum-1)*10,pagenum*10,city);
        return list;
    }

    public void delEmployment(int id){
        this.iEmploymentAdDao.delEmployment(id);
    }

    public List<EmploymentAd> selectByPersionalId(int personal_id){
        return this.iEmploymentAdDao.selectByPersionalId(personal_id);
    }
}
